package com.lovely3x.weightmeasurer.demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

import com.lovely3x.view.HeightView;

import java.math.BigDecimal;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    HeightView hv;
    EditText et_value;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        hv = findViewById(R.id.hv_y);
        et_value = findViewById(R.id.et_value);
//        hv.setOnItemChangedListener(new HeightView.OnItemChangedListener() {
//            @Override
//            public void onItemChanged(int index, int value) {
//                Log.i(TAG, String.format("onItemChanged index == %d value == %d ", index, value));
//            }
//        });
    }

    public void setValue(View view) {
        String value = et_value.getText().toString();
        int res = new BigDecimal(value)
                .divide(new BigDecimal("5"), 0, BigDecimal.ROUND_HALF_UP)
                .intValue();
        hv.setCurrentLineIndex(res);
    }
}
